<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>25.2. Using Zend_Locale</title>
<link rel="stylesheet" href="dbstyle.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.72.0">
<link rel="start" href="index.html" title="Programmer's Reference Guide">
<link rel="up" href="zend.locale.html" title="Chapter 25. Zend_Locale">
<link rel="prev" href="zend.locale.html" title="Chapter 25. Zend_Locale">
<link rel="next" href="zend.locale.parsing.html" title="25.3. Normalization and Localization">
<link rel="chapter" href="introduction.html" title="Chapter 1. Introduction to Zend Framework">
<link rel="chapter" href="zend.acl.html" title="Chapter 2. Zend_Acl">
<link rel="chapter" href="zend.auth.html" title="Chapter 3. Zend_Auth">
<link rel="chapter" href="zend.cache.html" title="Chapter 4. Zend_Cache">
<link rel="chapter" href="zend.config.html" title="Chapter 5. Zend_Config">
<link rel="chapter" href="zend.console.getopt.html" title="Chapter 6. Zend_Console_Getopt">
<link rel="chapter" href="zend.controller.html" title="Chapter 7. Zend_Controller">
<link rel="chapter" href="zend.currency.html" title="Chapter 8. Zend_Currency">
<link rel="chapter" href="zend.date.html" title="Chapter 9. Zend_Date">
<link rel="chapter" href="zend.db.html" title="Chapter 10. Zend_Db">
<link rel="chapter" href="zend.debug.html" title="Chapter 11. Zend_Debug">
<link rel="chapter" href="zend.dojo.html" title="Chapter 12. Zend_Dojo">
<link rel="chapter" href="zend.dom.html" title="Chapter 13. Zend_Dom">
<link rel="chapter" href="zend.exception.html" title="Chapter 14. Zend_Exception">
<link rel="chapter" href="zend.feed.html" title="Chapter 15. Zend_Feed">
<link rel="chapter" href="zend.filter.html" title="Chapter 16. Zend_Filter">
<link rel="chapter" href="zend.form.html" title="Chapter 17. Zend_Form">
<link rel="chapter" href="zend.gdata.html" title="Chapter 18. Zend_Gdata">
<link rel="chapter" href="zend.http.html" title="Chapter 19. Zend_Http">
<link rel="chapter" href="zend.infocard.html" title="Chapter 20. Zend_InfoCard">
<link rel="chapter" href="zend.json.html" title="Chapter 21. Zend_Json">
<link rel="chapter" href="zend.layout.html" title="Chapter 22. Zend_Layout">
<link rel="chapter" href="zend.ldap.html" title="Chapter 23. Zend_Ldap">
<link rel="chapter" href="zend.loader.html" title="Chapter 24. Zend_Loader">
<link rel="chapter" href="zend.locale.html" title="Chapter 25. Zend_Locale">
<link rel="chapter" href="zend.log.html" title="Chapter 26. Zend_Log">
<link rel="chapter" href="zend.mail.html" title="Chapter 27. Zend_Mail">
<link rel="chapter" href="zend.measure.html" title="Chapter 28. Zend_Measure">
<link rel="chapter" href="zend.memory.html" title="Chapter 29. Zend_Memory">
<link rel="chapter" href="zend.mime.html" title="Chapter 30. Zend_Mime">
<link rel="chapter" href="zend.openid.html" title="Chapter 31. Zend_OpenId">
<link rel="chapter" href="zend.paginator.html" title="Chapter 32. Zend_Paginator">
<link rel="chapter" href="zend.pdf.html" title="Chapter 33. Zend_Pdf">
<link rel="chapter" href="zend.registry.html" title="Chapter 34. Zend_Registry">
<link rel="chapter" href="zend.rest.html" title="Chapter 35. Zend_Rest">
<link rel="chapter" href="zend.search.lucene.html" title="Chapter 36. Zend_Search_Lucene">
<link rel="chapter" href="zend.server.html" title="Chapter 37. Zend_Server">
<link rel="chapter" href="zend.service.html" title="Chapter 38. Zend_Service">
<link rel="chapter" href="zend.session.html" title="Chapter 39. Zend_Session">
<link rel="chapter" href="zend.soap.html" title="Chapter 40. Zend_Soap">
<link rel="chapter" href="zend.test.html" title="Chapter 41. Zend_Test">
<link rel="chapter" href="zend.text.html" title="Chapter 42. Zend_Text">
<link rel="chapter" href="zend.timesync.html" title="Chapter 43. Zend_TimeSync">
<link rel="chapter" href="zend.translate.html" title="Chapter 44. Zend_Translate">
<link rel="chapter" href="zend.uri.html" title="Chapter 45. Zend_Uri">
<link rel="chapter" href="zend.validate.html" title="Chapter 46. Zend_Validate">
<link rel="chapter" href="zend.version.html" title="Chapter 47. Zend_Version">
<link rel="chapter" href="zend.view.html" title="Chapter 48. Zend_View">
<link rel="chapter" href="zend.xmlrpc.html" title="Chapter 49. Zend_XmlRpc">
<link rel="appendix" href="requirements.html" title="Appendix A. Zend Framework Requirements">
<link rel="appendix" href="coding-standard.html" title="Appendix B. Zend Framework Coding Standard for PHP">
<link rel="appendix" href="copyrights.html" title="Appendix C. Copyright Information">
<link rel="index" href="the.index.html" title="Index">
<link rel="subsection" href="zend.locale.functions.html#zend.locale.copying" title="25.2.1. Copying, Cloning, and Serializing Locale Objects">
<link rel="subsection" href="zend.locale.functions.html#zend.locale.equals" title="25.2.2. Equality">
<link rel="subsection" href="zend.locale.functions.html#zend.locale.getdefault" title="25.2.3. Default locales">
<link rel="subsection" href="zend.locale.functions.html#zend.locale.setlocale" title="25.2.4. Set a new locale">
<link rel="subsection" href="zend.locale.functions.html#zend.locale.getlocale" title="25.2.5. Getting the language and region">
<link rel="subsection" href="zend.locale.functions.html#zend.locale.getdata" title="25.2.6. Obtaining localized strings">
<link rel="subsection" href="zend.locale.functions.html#zend.locale.getquestion" title='25.2.7. Obtaining translations for "yes" and "no"'>
<link rel="subsection" href="zend.locale.functions.html#zend.locale.getlocalelist" title="25.2.8. Get a list of all known locales">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader"><table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">25.2. Using Zend_Locale</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="zend.locale.html">Prev</a> </td>
<th width="60%" align="center">Chapter 25. Zend_Locale</th>
<td width="20%" align="right"> <a accesskey="n" href="zend.locale.parsing.html">Next</a>
</td>
</tr>
</table></div>
<div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="zend.locale.functions"></a>25.2. Using Zend_Locale</h2></div></div></div>
<p>
        <code class="code">Zend_Locale</code> also provides localized information about locales for each locale,
        including localized names for other locales, days of the week, month names, etc.
    </p>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.copying"></a>25.2.1. Copying, Cloning, and Serializing Locale Objects</h3></div></div></div>
<p>
            Use
            <a href="http://php.net/language.oop5.cloning" target="_top">object cloning</a>
            to duplicate a locale object exactly and efficiently. Most locale-aware methods also accept string
            representations of locales, such as the result of <code class="code">$locale-&gt;toString()</code>.
        </p>
<div class="example">
<a name="zend.locale.copying.example-1"></a><p class="title"><b>Example 25.11. clone</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('ar');

// Save the $locale object as a serialization
$serializedLocale = $locale-&gt;serialize();
// re-create the original object
$localeObject = unserialize($serializedLocale);

// Obtain a string identification of the locale
$stringLocale = $locale-&gt;toString();

// Make a cloned copy of the $local object
$copiedLocale = clone $locale;

print "copied: ", $copiedLocale-&gt;toString();
print "copied: ", $copiedLocale; // PHP automatically calls toString() via __toString();
            </pre></div>
</div>
<br class="example-break">
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.equals"></a>25.2.2. Equality</h3></div></div></div>
<p>
            <code class="code">Zend_Locale</code> also provides a convenience function to compare two locales. All locale-aware
            classes should provide a similar equality check.
        </p>
<div class="example">
<a name="zend.locale.equals.example-1"></a><p class="title"><b>Example 25.12. Check for equal locales</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale();
$mylocale = new Zend_Locale('en_US');

// Check if locales are equal
if ($locale-&gt;equals($mylocale)) {
    print "Locales are equal";
}
            </pre></div>
</div>
<br class="example-break">
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.getdefault"></a>25.2.3. Default locales</h3></div></div></div>
<p>
            The method <code class="code">getDefault()</code> returns an array of relevant locales using information from the user's
            web browser (if available), information from the environment of the host server, and ZF settings. As with
            the constructor for <code class="code">Zend_Locale</code>, the first parameter selects a preference of which information
            to consider
            <a href="zend.locale.html#zend.locale.selection" title="25.1.4. Selecting the Right Locale">(<code class="code">BROWSER</code>, <code class="code">ENVIRONMENT</code>, or <code class="code">FRAMEWORK)</code>
            </a>
            first. The second parameter toggles between returning all matching locales or only the first/best match.
            Locale-aware components normally use only the first locale. A quality rating is included, when available.
        </p>
<div class="example">
<a name="zend.locale.getdefault.example-1"></a><p class="title"><b>Example 25.13. Get default locales</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale();

// Return all default locales
$found = $locale-&gt;getDefault();
print_r($found);

// Return only browser locales
$found2 = $locale-&gt;getDefault(Zend_Locale::BROWSER,TRUE);
print_r($found2);
            </pre></div>
</div>
<br class="example-break"><p>
            To obtain only the default locales relevent to the
            <a href="zend.locale.html#zend.locale.selection" title="25.1.4. Selecting the Right Locale"><code class="code">BROWSER</code>, <code class="code">ENVIRONMENT</code>, or <code class="code">FRAMEWORK</code>
            </a>
            , use the corresponding method:
            </p>
<div class="itemizedlist"><ul type="disc">
<li><p>
                        <code class="code">getEnvironment()</code>
                    </p></li>
<li><p>
                        <code class="code">getBrowser()</code>
                    </p></li>
<li><p>
                        <code class="code">getLocale()</code>
                    </p></li>
</ul></div>
<p>
        </p>
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.setlocale"></a>25.2.4. Set a new locale</h3></div></div></div>
<p>
            A new locale can be set with the function <code class="code">setLocale()</code>. This function takes a locale string as
            parameter. If no locale is given, a locale is
            <a href="zend.locale.html#zend.locale.selection" title="25.1.4. Selecting the Right Locale">automatically selected</a>
            . Since Zend_Locale objects are "light", this method exists primarily to cause side-effects for code that
            have references to the existing instance object.
        </p>
<div class="example">
<a name="zend.locale.setlocale.example-1"></a><p class="title"><b>Example 25.14. setLocale</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale();

// Actual locale
print $locale-&gt;toString();

// new locale
$locale-&gt;setLocale('aa_DJ');
print $locale-&gt;toString();
            </pre></div>
</div>
<br class="example-break">
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.getlocale"></a>25.2.5. Getting the language and region</h3></div></div></div>
<p>
            Use <code class="code">getLanguage()</code> to obtain a string containing the two character language code from the string
            locale identifier. Use <code class="code">getRegion()</code> to obtain a string containing the two character region code
            from the string locale identifier.
        </p>
<div class="example">
<a name="zend.locale.getlocale.example-1"></a><p class="title"><b>Example 25.15. getLanguage and getRegion</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale();

// if locale is 'de_AT' then 'de' will be returned as language
print $locale-&gt;getLanguage();

// if locale is 'de_AT' then 'AT' will be returned as region
print $locale-&gt;getRegion();
            </pre></div>
</div>
<br class="example-break">
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.getdata"></a>25.2.6. Obtaining localized strings</h3></div></div></div>
<p>
            <code class="code">getTranslationList()</code> gives you access to localized informations of several types. These
            information are useful if you want to display localized data to a customer without the need
            of translating it. They are already available for your usage.
        </p>
<p>
            The requested list of information is always returned as named array. If you want to give more than
            one value to a explicit type where you wish to receive values from, you have to give an array
            instead of multiple values.
        </p>
<div class="example">
<a name="zend.locale.getdata.example-1"></a><p class="title"><b>Example 25.16. getTranslationList</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('de_AT');
$list = $locale-&gt;getTranslationList('language');

print_r ($list);
// example key -&gt; value pairs...
// [de] -&gt; Deutsch
// [en] -&gt; Englisch

// use one of the returned key as value for the getTranslation() method of another language
print $locale-&gt;getTranslation('de', 'language', 'zh');
// returns the translation for the language 'de' in chinese
            </pre></div>
</div>
<br class="example-break"><p>
            You can receive this informations for all languages. But not all of the informations are completly
            available for all languages. Some of these types are also available through an own function for
            simplicity. See this list for detailed informations.
        </p>
<div class="table">
<a name="zend.locale.getdata.table-1"></a><p class="title"><b>Table 25.1. Details for getTranslationList($type = null, $locale = null, $value = null)</b></p>
<div class="table-contents"><table summary="Details for getTranslationList($type = null, $locale = null, $value = null)" border="1">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tbody>
<tr>
<td><span class="strong"><strong>Language</strong></span></td>
<td>Returns a localized list of all languages. The language part of the locale
                            is returned as key and the translation as value. For your convinience use the
                            <code class="code">getLanguageTranslationList()</code> method</td>
</tr>
<tr>
<td><span class="strong"><strong>Script</strong></span></td>
<td>Returns a localized list of all scripts. The script is returned as key and the
                            translation as value. For your convinience use the
                            <code class="code">getScriptTranslationList()</code> method</td>
</tr>
<tr>
<td><span class="strong"><strong>Territory</strong></span></td>
<td>Returns a localized list of all territories. This contains countries,
                            continents and territories. To get only territories and continents
                            use '1' as value. To get only countries use '2' as value. The country part of
                            the locale is used as key where applicable. In the other case the official ISO
                            code for this territory is used. The translated territory is returned as value.
                            For your convinience use the <code class="code">getCountryTranslationList()</code> method
                            to receive all countries and the <code class="code">getTerritoryTranslationList()</code>
                            method to receive all territories without countries. When you omit the value
                            you will get a list with both.</td>
</tr>
<tr>
<td><span class="strong"><strong>Variant</strong></span></td>
<td>Returns a localized list of known variants of scripts. The variant is
                            returned as key and the translation as value</td>
</tr>
<tr>
<td><span class="strong"><strong>Key</strong></span></td>
<td>Returns a localized list of known keys. This keys are generic values used
                            in translation. These are normally calendar, collation and currency. The key
                            is returned as array key and the translation as value</td>
</tr>
<tr>
<td><span class="strong"><strong>Type</strong></span></td>
<td>Returns a localized list of known types of keys. These are variants of types
                            of calendar representations and types of collations. When you use 'collation' as
                            value you will get all types of collations returned. When you use 'calendar' as
                            value you will get all types of calendars returned. When you omit the value you
                            will get a list all both returned. The type is used as key and the translation as
                            value</td>
</tr>
<tr>
<td><span class="strong"><strong>Layout</strong></span></td>
<td>Returns a list of rules which describes how to format special text parts</td>
</tr>
<tr>
<td><span class="strong"><strong>Characters</strong></span></td>
<td>Returns a list of allowed characters within this locale</td>
</tr>
<tr>
<td><span class="strong"><strong>Delimiters</strong></span></td>
<td>Returns a list of allowed quoting characters for this locale</td>
</tr>
<tr>
<td><span class="strong"><strong>Measurement</strong></span></td>
<td>Returns a list of known measurement values. This list is depreciated</td>
</tr>
<tr>
<td><span class="strong"><strong>Months</strong></span></td>
<td>Returns a list of all month representations within this locale. There are
                            several different represenations which are all returned as sub array. If you omit
                            the value you will get a list of all months from the 'gregorian' calendar returned.
                            You can give any known calendar as value to get a list of months from this calendar
                            returned. Use <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for
                            simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Month</strong></span></td>
<td>Returns a localized list of all month names for this locale. If you omit the
                            value you will get the normally used gregorian full name of the months where each
                            month number is used as key and the translated month is returned as value. You
                            can get the months for different calendars and formats if you give an array as value.
                            The first array entry has to be the calendar, the second the used context and the
                            third the width to return. Use <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a>
                            for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Days</strong></span></td>
<td>Returns a list of all day representations within this locale. There are
                            several different represenations which are all returned as sub array. If you omit
                            the value you will get a list of all days from the 'gregorian' calendar returned.
                            You can give any known calendar as value to get a list of days from this calendar
                            returned. Use <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for
                            simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Day</strong></span></td>
<td>Returns a localized list of all day names for this locale. If you omit the
                            value you will get the normally used gregorian full name of the days where the
                            english day abbreviation is used as key and the translated day is returned as
                            value. You can get the days for different calendars and formats if you give an
                            array as value. The first array entry has to be the calendar, the second the used
                            context and the third the width to return. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Week</strong></span></td>
<td>Returns a list of values used for proper week calculations within a locale.
                            Use <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Quarters</strong></span></td>
<td>Returns a list of all quarter representations within this locale. There are
                            several different represenations which are all returned as sub array. If you omit
                            the value you will get a list of all quarters from the 'gregorian' calendar returned.
                            You can give any known calendar as value to get a list of quarters from this calendar
                            returned</td>
</tr>
<tr>
<td><span class="strong"><strong>Quarter</strong></span></td>
<td>Returns a localized list of all quarter names for this locale. If you omit the
                            value you will get the normally used gregorian full name of the quarters where each
                            quarter number is used as key and the translated quarter is returned as value. You
                            can get the quarters for different calendars and formats if you give an array as
                            value. The first array entry has to be the calendar, the second the used context
                            and the third the width to return</td>
</tr>
<tr>
<td><span class="strong"><strong>Eras</strong></span></td>
<td>Returns a list of all era representations within this locale. If you omit
                            the value you will get a list of all eras from the 'gregorian' calendar returned.
                            You can give any known calendar as value to get a list of eras from this calendar
                            returned</td>
</tr>
<tr>
<td><span class="strong"><strong>Era</strong></span></td>
<td>Returns a localized list of all era names for this locale. If you omit the
                            value you will get the normally used gregorian full name of the eras where each
                            era number is used as key and the translated era is returned as value. You
                            can get the eras for different calendars and formats if you give an array as
                            value. The first array entry has to be the calendar and the second the width to
                            return</td>
</tr>
<tr>
<td><span class="strong"><strong>Date</strong></span></td>
<td>Returns a localized list of all date formats for this locale. The name of the
                            dateformat is used as key and the format itself as value.If you omit the value you
                            will get the date formats for the gregorian calendar returned. You can get the
                            date formats for different calendars if you give the wished calendar as string.
                            Use <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Time</strong></span></td>
<td>Returns a localized list of all time formats for this locale. The name of the
                            timeformat is used as key and the format itself as value. If you omit the value you
                            will get the time formats for the gregorian calendar returned. You can get the
                            time formats for different calendars if you give the wished calendar as string.
                            Use <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>DateTime</strong></span></td>
<td>Returns a localized list of all known date-time formats for this locale. The name
                            of the date-time format is used as key and the format itself as value. If you
                            omit the value you will get the date-time formats for the gregorian calendar returned.
                            You can get the date-time formats for different calendars if you give the wished
                            calendar as string. Use <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a>
                            for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Field</strong></span></td>
<td>Returns a localized list of date fields which can be used to display calendars
                            or date strings like 'month' or 'year' in a wished language. If you omit the value
                            you will get this list for the gregorian calendar returned. You can get the
                            list for different calendars if you give the wished calendar as string</td>
</tr>
<tr>
<td><span class="strong"><strong>Relative</strong></span></td>
<td>Returns a localized list of relative dates which can be used to display
                            textual relative dates like 'yesterday' or 'tomorrow' in a wished language.
                            If you omit the value you will get this list for the gregorian calendar
                            returned. You can get the list for different calendars if you give the wished
                            calendar as string</td>
</tr>
<tr>
<td><span class="strong"><strong>Symbols</strong></span></td>
<td>Returns a localized list of characters used for number representations</td>
</tr>
<tr>
<td><span class="strong"><strong>NameToCurrency</strong></span></td>
<td>Returns a localized list of names for currencies. The currency is used as key
                            and the translated name as value. Use
                            <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>CurrencyToName</strong></span></td>
<td>Returns a list of currencies for localized names. The translated name is used
                            as key and the currency as value. Use
                            <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>CurrencySymbol</strong></span></td>
<td>Returns a list of known localized currency symbols for currencies. The
                            currency is used as key and the symbol as value. Use
                            <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Question</strong></span></td>
<td>Returns a list of localized strings for acceptance ('yes') and
                            negotation ('no'). Use
                            <a href="zend.locale.functions.html#zend.locale.getquestion" title='25.2.7. Obtaining translations for "yes" and "no"'>Zend_Locale's getQuestion method</a>
                            for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>CurrencyFraction</strong></span></td>
<td>Returns a list of fractions for currency values. The currency is used as key and
                            the fraction as integer value. Use
                            <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>CurrencyRounding</strong></span></td>
<td>Returns a list of how to round which currency. The currency is used as key and
                            the rounding as integer value. Use
                            <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>CurrencyToRegion</strong></span></td>
<td>Returns a list of currencies which are known to be used within a region.
                            The ISO3166 value ('region') is used as array key and the ISO4217 value
                            ('currency') as array value. Use
                            <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>RegionToCurrency</strong></span></td>
<td>Returns a list of regions where a currency is used . The ISO4217 value ('currency')
                            is used as array key and the ISO3166 value ('region') as array value. When a currency
                            is used in several regions these regions are seperated with a whitespace. Use
                            <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>RegionToTerritory</strong></span></td>
<td>Returns a list of territories with the countries or sub territories which are
                            included within that territory. The ISO territory code ('territory') is used as
                            array key and the ISO3166 value ('region') as array value. When a territory contains
                            several regions these regions are seperated with a whitespace</td>
</tr>
<tr>
<td><span class="strong"><strong>TerritoryToRegion</strong></span></td>
<td>Returns a list of regions and the territories where these regions are located.
                            The ISO3166 code ('region') is used as array key and the ISO territory code
                            ('territory') as array value. When a region is located in several territories
                            these territories are seperated with a whitespace</td>
</tr>
<tr>
<td><span class="strong"><strong>ScriptToLanguage</strong></span></td>
<td>Returns a list of scripts which are used within a language. The language code
                            is used as array key and the script code as array value. When a language contains
                            several scripts these scripts are seperated with a whitespace</td>
</tr>
<tr>
<td><span class="strong"><strong>LanguageToScript</strong></span></td>
<td>Returns a list of languages which are using a script. The script code
                            is used as array key and the language code as array value. When a script is used
                            in several languages these languages are seperated with a whitespace</td>
</tr>
<tr>
<td><span class="strong"><strong>TerritoryToLanguage</strong></span></td>
<td>Returns a list of countries which are using a language. The country code
                            is used as array key and the language code as array value. When a language is used in
                            several countries these countries are seperated with a whitespace</td>
</tr>
<tr>
<td><span class="strong"><strong>LanguageToTerritory</strong></span></td>
<td>Returns a list of countries and the languages spoken within these countries.
                            The country code is used as array key and the language code as array value. When
                            a territory is using several languages these languages are seperated with a
                            whitespace</td>
</tr>
<tr>
<td><span class="strong"><strong>TimezoneToWindows</strong></span></td>
<td>Returns a list of windows timezones and the related ISO timezone. The windows
                            timezone is used as array key and the ISO timezone as array value</td>
</tr>
<tr>
<td><span class="strong"><strong>WindowsToTimezone</strong></span></td>
<td>Returns a list of ISO timezones and the related windows timezone. The ISO
                            timezone is used as array key and the windows timezone as array value</td>
</tr>
<tr>
<td><span class="strong"><strong>TerritoryToTimezone</strong></span></td>
<td>Returns a list of regions or territories and the related ISO timezone. The
                            ISO timezone is used as array key and the territory code as array value</td>
</tr>
<tr>
<td><span class="strong"><strong>TimezoneToTerritory</strong></span></td>
<td>Returns a list of timezones and the related region or territory code. The
                            region or territory code is used as array key and the ISO timezone as array
                            value</td>
</tr>
<tr>
<td><span class="strong"><strong>CityToTimezone</strong></span></td>
<td>Returns a localized list of cities which can be used as translation for a
                            related timezone. Not for all timezones is a translation available, but for a
                            user is the real city written in his languages more accurate than the ISO name
                            of this timezone. The ISO timezone is used as array key and the translated
                            city as array value</td>
</tr>
<tr>
<td><span class="strong"><strong>TimezoneToCity</strong></span></td>
<td>Returns a list of timezones for localized city names. The localized city is
                            used as array key and the ISO timezone name as array value</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>
            If you are in need of a single translated value, you can use the <code class="code">getTranslation()</code>
            method. It returns always a string but it accepts some different types than the
            <code class="code">getTranslationList()</code> method. Also value is the same as before with one difference.
            You have to give the detail you want to get returned as additional value.
        </p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
                Because you have almost always give a value as detail this parameter has to be given
                as first parameter. This differs from the <code class="code">getTranslationList()</code> method.
            </p></td></tr>
</table></div>
<p>
            See the following table for detailed informations: 
        </p>
<div class="table">
<a name="zend.locale.getdata.table-2"></a><p class="title"><b>Table 25.2. Details for getTranslation($value = null, $type = null, $locale = null)</b></p>
<div class="table-contents"><table summary="Details for getTranslation($value = null, $type = null, $locale = null)" border="1">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tbody>
<tr>
<td><span class="strong"><strong>Language</strong></span></td>
<td>Returns a translation for a language. To select the wished translation
                            you must give the language code as value. For your convinience use the
                            <code class="code">getLanguageTranslation($value)</code> method</td>
</tr>
<tr>
<td><span class="strong"><strong>Script</strong></span></td>
<td>Returns a translation for a script. To select the wished translation you
                            must give the script code as value. For your convinience use the
                            <code class="code">getScriptTranslation($value)</code> method</td>
</tr>
<tr>
<td>
<span class="strong"><strong>Territory</strong></span> or
                            <span class="strong"><strong>Country</strong></span>
</td>
<td>Returns a translation for a territory. This can be countries, continents
                            and territories. To select the wished variant you must give the territory
                            code as value. For your convinience use the
                            <code class="code">getCountryTranslation($value)</code> method.</td>
</tr>
<tr>
<td><span class="strong"><strong>Variant</strong></span></td>
<td>Returns a translation for a script variant. To select the wished variant
                            you must give the variant code as value</td>
</tr>
<tr>
<td><span class="strong"><strong>Key</strong></span></td>
<td>Returns translation for a known keys. This keys are generic values used
                            in translation. These are normally calendar, collation and currency. To
                            select the wished key you must give the key code as value</td>
</tr>
<tr>
<td><span class="strong"><strong>DateChars</strong></span></td>
<td>Returns a character table which contains all characters used when displaying
                            dates</td>
</tr>
<tr>
<td><span class="strong"><strong>DefaultCalendar</strong></span></td>
<td>Returns the default calendar for the given locale. For most locales this
                            will be 'gregorian'. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>MonthContext</strong></span></td>
<td>Returns the default context for months which is used within the given
                            calendar. If you omit the value the 'gregorian' calendar will be used. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>DefaultMonth</strong></span></td>
<td>Returns the default format for months which is used within the given
                            calendar. If you omit the value the 'gregorian' calendar will be used. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Month</strong></span></td>
<td>Returns a translation for a month. You have to give the number of the month
                            as integer value. It has to be between 1 and 12. If you want to receive data for
                            other calendars, contexts or formats, then you must give an array instead of an
                            integer with the expected values. The array has to look like this: <code class="code">array(
                            'calendar', 'context', 'format', 'month number')</code>. If you give only an
                            integer then the default values are the 'gregorian' calendar, the context
                            'format' and the format 'wide'. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>DayContext</strong></span></td>
<td>Returns the default context for ´days which is used within the given
                            calendar. If you omit the value the 'gregorian' calendar will be used. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>DefaultDay</strong></span></td>
<td>Returns the default format for days which is used within the given
                            calendar. If you omit the value the 'gregorian' calendar will be used. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Day</strong></span></td>
<td>Returns a translation for a day. You have to give the english abbreviation
                            of the day as string value ('sun', 'mon', etc.). If you want to receive data
                            for other calendars, contexts or format, then you must give an array instead of
                            an integer with the expected values. The array has to look like this:
                            <code class="code">array('calendar', 'context', 'format', 'day abbreviation')</code>. If you
                            give only an string then the default values are the 'gregorian' calendar,
                            the context 'format' and the format 'wide'. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Quarter</strong></span></td>
<td>Returns a translation for a quarter. You have to give the number of the
                            quarter as integer and it has to be between 1 and 4. If you want to receive
                            data for other calendars, contexts or formats, then you must give an array
                            instead of an integer with the expected values. The array has to look like this:
                            <code class="code">array('calendar', 'context', 'format', 'quarter number')</code>. If you
                            give only an string then the default values are the 'gregorian' calendar,
                            the context 'format' and the format 'wide'</td>
</tr>
<tr>
<td><span class="strong"><strong>Am</strong></span></td>
<td>Returns a translation for 'AM' in a expected locale. If you want to receive
                            data for other calendars an string with the expected calendar. If you omit the
                            value then the 'gregorian' calendar will be used. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Pm</strong></span></td>
<td>Returns a translation for 'PM' in a expected locale. If you want to receive
                            data for other calendars an string with the expected calendar. If you omit the
                            value then the 'gregorian' calendar will be used. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Era</strong></span></td>
<td>Returns a translation for an era within a locale. You have to give the era
                            number as string or integer. If you want to receive data for other calendars or
                            formats, then you must give an array instead of the era number with the expected
                            values. The array has to look like this:
                            <code class="code">array('calendar', 'format', 'era number')</code>. If you give only an
                            string then the default values are the 'gregorian' calendar and the 'abbr'
                            format</td>
</tr>
<tr>
<td><span class="strong"><strong>DefaultDate</strong></span></td>
<td>Returns the default date format which is used within the given
                            calendar. If you omit the value the 'gregorian' calendar will be used. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Date</strong></span></td>
<td>Returns the date format for an given calendar or format within a locale.
                            If you omit the value then the 'gregorian' calendar will be used with the
                            'medium' format. If you give a string then the 'gregorian' calendar will be
                            used with the given format. Or you can also give an array which will have to
                            look like this: <code class="code">array('calendar', 'format')</code>. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>DefaultTime</strong></span></td>
<td>Returns the default time format which is used within the given
                            calendar. If you omit the value the 'gregorian' calendar will be used. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Time</strong></span></td>
<td>Returns the time format for an given calendar or format within a locale.
                            If you omit the value then the 'gregorian' calendar will be used with the
                            'medium' format. If you give a string then the 'gregorian' calendar will be
                            used with the given format. Or you can also give an array which will have to
                            look like this: <code class="code">array('calendar', 'format')</code>. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>DateTime</strong></span></td>
<td>Returns the datetime format for the given locale which indicates how to
                            display date with times in the same string within the given calendar. If you
                            omit the value the 'gregorian' calendar will be used. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Field</strong></span></td>
<td>Returns a translated date field which can be used to display calendars or
                            date strings like 'month' or 'year' in a wished language. You must give the
                            field which has to be returned as string. In this case the 'gregorian'
                            calendar will be used. You can get the field for other calendar formats if you
                            give an array which has to look like this:
                            <code class="code">array('calendar', 'date field')</code>
</td>
</tr>
<tr>
<td><span class="strong"><strong>Relative</strong></span></td>
<td>Returns a translated date which is relative to today which can include date
                            strings like 'yesterday' or 'tomorrow' in a wished language. You have to give
                            the number of days relative to tomorrow to receive the expected string. Yesterday
                            would be '-1', tomorrow '1' and so on. This will use the 'gregorian' calendar. If
                            you want to get relative dates for other calendars you will have to give an array
                            which has to look like this: <code class="code">array('calendar', 'relative days')</code>. Use
                            <a href="zend.date.html#zend.date.introduction" title="9.1. Introduction">Zend_Date</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>DecimalNumber</strong></span></td>
<td>Returns the format for decimal numbers within a given locale. Use
                            <a href="zend.locale.parsing.html" title="25.3. Normalization and Localization">Zend_Locale_Format</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>ScientificNumber</strong></span></td>
<td>Returns the format for scientific numbers within a given locale</td>
</tr>
<tr>
<td><span class="strong"><strong>PercentNumber</strong></span></td>
<td>Returns the format for percentage numbers within a given locale</td>
</tr>
<tr>
<td><span class="strong"><strong>CurrencyNumber</strong></span></td>
<td>Returns the format for displaying currency numbers within a given locale. Use
                            <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>NameToCurrency</strong></span></td>
<td>Returns the translated name for a given currency. The currency has to be
                            given in ISO format which is for example 'EUR' for the currency 'euro'. Use
                            <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>CurrencyToName</strong></span></td>
<td>Returns a currency for a given localized name. Use
                            <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>CurrencySymbol</strong></span></td>
<td>Returns the used symbol for a currency within a given locale. Not for all
                            currencies exists a symbol. Use
                            <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>Question</strong></span></td>
<td>Returns a localized string for acceptance ('yes') and
                            negotation ('no'). You have to give either 'yes' or 'no' as value to receive the
                            expected string. Use
                            <a href="zend.locale.functions.html#zend.locale.getquestion" title='25.2.7. Obtaining translations for "yes" and "no"'>Zend_Locale's getQuestion method</a>
                            for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>CurrencyFraction</strong></span></td>
<td>Returns the fraction to use for a given currency. You must give the currency
                            as ISO value. Use <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a>
                            for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>CurrencyRounding</strong></span></td>
<td>Returns how to round a given currency. You must give the currency
                            as ISO value. If you omit the currency then the 'DEFAULT' rounding will be
                            returned. Use <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a>
                            for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>CurrencyToRegion</strong></span></td>
<td>Returns the currency for a given region. The region code has to be given
                            as ISO3166 string for example 'AT' for austria. Use
                            <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>RegionToCurrency</strong></span></td>
<td>Returns the regions where a currency is used. The currency has to be given
                            as ISO4217 code for example 'EUR' for euro. When a currency is used in multiple
                            regions, these regions are seperated with a whitespace character. Use
                            <a href="zend.currency.html#zend.currency.introduction" title="8.1. Introduction to Zend_Currency">Zend_Currency</a> for simplicity</td>
</tr>
<tr>
<td><span class="strong"><strong>RegionToTerritory</strong></span></td>
<td>Returns the regions for a given territory. The territory has to be given as
                            ISO4217 string for example '001' for world. The regions within this territory
                            are seperated with a whitespace character</td>
</tr>
<tr>
<td><span class="strong"><strong>TerritoryToRegion</strong></span></td>
<td>Returns the territories where a given region is located. The region has to be
                            given in ISO3166 string for example 'AT' for austria. When a region is located in
                            multiple territories then these territories are seperated with a whitespace
                            character</td>
</tr>
<tr>
<td><span class="strong"><strong>ScriptToLanguage</strong></span></td>
<td>Returns the scripts which are used within a given language. The language has
                            to be given as ISO language code for example 'en' for english. When multiple
                            scripts are used within a language then these scripts are seperated with a
                            whitespace character</td>
</tr>
<tr>
<td><span class="strong"><strong>LanguageToScript</strong></span></td>
<td>Returns the languages which are used within a given script. The script has to be
                            given as ISO script code for example 'Latn' for latin. When a script is used in
                            multiple languages then these languages are seperated with a whitespace
                            character</td>
</tr>
<tr>
<td><span class="strong"><strong>TerritoryToLanguage</strong></span></td>
<td>Returns the territories where a given language is used. The language has
                            to be given as ISO language code for example 'en' for english. When multiple
                            territories exist where this language is used then these territories are
                            seperated with a whitespace character</td>
</tr>
<tr>
<td><span class="strong"><strong>LanguageToTerritory</strong></span></td>
<td>Returns the languages which are used within a given territory. The territory
                            has to be given as ISO3166 code for example 'IT' for italia. When a language
                            is used in multiple territories then these territories are seperated with a
                            whitespace character</td>
</tr>
<tr>
<td><span class="strong"><strong>TimezoneToWindows</strong></span></td>
<td>Returns a ISO timezone for a given windows timezone</td>
</tr>
<tr>
<td><span class="strong"><strong>WindowsToTimezone</strong></span></td>
<td>Returns a windows timezone for a given ISO timezone</td>
</tr>
<tr>
<td><span class="strong"><strong>TerritoryToTimezone</strong></span></td>
<td>Returns the territory for a given ISO timezone</td>
</tr>
<tr>
<td><span class="strong"><strong>TimezoneToTerritory</strong></span></td>
<td>Returns the ISO timezone for a given territory</td>
</tr>
<tr>
<td><span class="strong"><strong>CityToTimezone</strong></span></td>
<td>Returns the localized city for a given ISO timezone. Not for all timezones
                            does a city translation exist</td>
</tr>
<tr>
<td><span class="strong"><strong>TimezoneToCity</strong></span></td>
<td>Returns the ISO timezone for a given localized city name. Not for all cities
                            does a timezone exist</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
                With Zend Framework 1.5 several old types have been renamed. This has to be done because
                of several new types, some misspelling and to increase the usability. See this table for
                a list of old to new types:  
            </p></td></tr>
</table></div>
<div class="table">
<a name="zend.locale.getdata.table-3"></a><p class="title"><b>Table 25.3. Differences between ZF 1.0 and ZF 1.5</b></p>
<div class="table-contents"><table summary="Differences between ZF 1.0 and ZF 1.5" border="1">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>Old type</th>
<th>New type</th>
</tr></thead>
<tbody>
<tr>
<td>Country</td>
<td>Territory (with value '2')</td>
</tr>
<tr>
<td>Calendar</td>
<td>Type (with value 'calendar')</td>
</tr>
<tr>
<td>Month_Short</td>
<td>Month (with array('gregorian', 'format', 'abbreviated')</td>
</tr>
<tr>
<td>Month_Narrow</td>
<td>Month (with array('gregorian', 'stand-alone', 'narrow')</td>
</tr>
<tr>
<td>Month_Complete</td>
<td>Months</td>
</tr>
<tr>
<td>Day_Short</td>
<td>Day (with array('gregorian', 'format', 'abbreviated')</td>
</tr>
<tr>
<td>Day_Narrow</td>
<td>Day (with array('gregorian', 'stand-alone', 'narrow')</td>
</tr>
<tr>
<td>DateFormat</td>
<td>Date</td>
</tr>
<tr>
<td>TimeFormat</td>
<td>Time</td>
</tr>
<tr>
<td>Timezones</td>
<td>CityToTimezone</td>
</tr>
<tr>
<td>Currency</td>
<td>NameToCurrency</td>
</tr>
<tr>
<td>Currency_Sign</td>
<td>CurrencySymbol</td>
</tr>
<tr>
<td>Currency_Detail</td>
<td>CurrencyToRegion</td>
</tr>
<tr>
<td>Territory_Detail</td>
<td>TerritoryToRegion</td>
</tr>
<tr>
<td>Language_Detail</td>
<td>LanguageToTerritory</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>
            The example below demonstrates how to obtain the names of things in different languages.
        </p>
<div class="example">
<a name="zend.locale.getdata.example-3"></a><p class="title"><b>Example 25.17. getTranslationList</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('en_US');
// prints the names of all countries in German language
print_r($locale-&gt;getTranslationList('country', 'de'));
            </pre></div>
</div>
<br class="example-break"><p>
            The next example shows how to find the name of a language in another language, when the two letter
            iso country code is not known.
        </p>
<div class="example">
<a name="zend.locale.getdata.example-4"></a><p class="title"><b>Example 25.18. Converting country name in one language to another</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require 'Zend/Locale.php';
$locale = new Zend_Locale('en_US');
$code2name = $locale-&gt;getLanguageTranslationList();
$name2code = array_flip($code2name);
$frenchCode = $name2code['French'];
echo $locale-&gt;getLanguageTranslation($frenchCode, 'de_AT');
// output is the German name of the French language
            </pre></div>
</div>
<br class="example-break"><p>
            To gain some familiarity with what is available, try the example and examine the output.
        </p>
<div class="example">
<a name="zend.locale.getdata.example-5"></a><p class="title"><b>Example 25.19. All available translations</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
// obtain a list of all the translation lists
$lists = $locale-&gt;getTranslationList();

// show all translation lists available (lots of output, all in English language)
foreach ($lists as $list) {
    echo "List $list = ";
    print_r($locale-&gt;getTranslationList($list));
}
            </pre></div>
</div>
<br class="example-break"><p>
            To generate a list of all languages known by Zend_Locale, with each language name shown in its own language,
            try the example below in a web page. Similarly, <code class="code">getCountryTranslationList()</code> and
            <code class="code">getCountryTranslation()</code> could be used to create a table mapping your native language names for
            regions to the names of the regions shown in another language. Use a
            <code class="code">try .. catch</code> block to handle exceptions that occur when using a locale that does not exist. Not
            all languages are also locales. In the example, below exceptions are ignored to prevent early termination.
        </p>
<div class="example">
<a name="zend.locale.getdata.example-6"></a><p class="title"><b>Example 25.20. All Languages written in their native language</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$sourceLanguage = null; // set to your native language code
$locale = new Zend_Locale($sourceLanguage);
$list = $locale-&gt;getLanguageTranslationList();

foreach($list as $language =&gt; $content) {
    try {
        $output = $locale-&gt;getLanguageTranslation($language, $language);
        if (is_string($output)) {
            print "\n&lt;br&gt;[".$language."] ".$output;
        }
    } catch (Exception $e) {
        continue;
    }
}
            </pre></div>
</div>
<br class="example-break">
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.getquestion"></a>25.2.7. Obtaining translations for "yes" and "no"</h3></div></div></div>
<p>
            Frequently, programs need to solicit a "yes" or "no" response from the user. Use <code class="code">getQuestion()</code>
            to obtain an array containing the correct word(s) or regex strings to use for prompting the user in a
            particular $locale (defaults to the current object's locale). The returned array will contain the
            following informations :
        </p>
<div class="itemizedlist"><ul type="disc"><li>
<p>
                    <span class="strong"><strong>yes and no</strong></span>: A generic string representation for yes
                    and no responses. This will contain the first and most generic response from yesarray and
                    noarray.
                </p>
<p>
                    <span class="strong"><strong>yesarray and noarray</strong></span>: An array with all known yes and
                    no responses. Several languages have more than just two responses. In general this is the
                    full string and it's abbreviation.
                </p>
<p>
                    <span class="strong"><strong>yesexpr and noexpr</strong></span>: An generated regex which allows you
                    to handle user response, and search for yes or no.
                </p>
</li></ul></div>
<p>
            All of this informations are of course localized and depend on the set locale. See the following
            example for the informations you can receive:
        </p>
<div class="example">
<a name="zend.locale.getquestion.example-1"></a><p class="title"><b>Example 25.21. getQuestion()</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale();
// Question strings
print_r($locale-&gt;getQuestion('de'));

- - - Output - - -

Array
(
    [yes] =&gt; ja
    [no] =&gt; nein
    [yesarray] =&gt; Array
        (
            [0] =&gt; ja
            [1] =&gt; j
        )

    [noarray] =&gt; Array
        (
            [0] =&gt; nein
            [1] =&gt; n
        )

    [yesexpr] =&gt; ^([jJ][aA]?)|([jJ]?)
    [noexpr] =&gt; ^([nN]([eE][iI][nN])?)|([nN]?)
)
            </pre></div>
</div>
<br class="example-break"><div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
                Until 1.0.3 <span class="strong"><strong>yesabbr</strong></span> from the underlaying locale data was also
                available. Since 1.5 this information is no longer standalone available, but you will find the
                information from it within <span class="strong"><strong>yesarray</strong></span>.
            </p></td></tr>
</table></div>
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.getlocalelist"></a>25.2.8. Get a list of all known locales</h3></div></div></div>
<p>
            Sometimes you will want to get a list of all known locales. This can be used for several tasks
            like the creation of a selectbox. For this purpose you can use the static
            <code class="code">getLocaleList()</code> method which will return a list of all known locales.
        </p>
<div class="example">
<a name="zend.locale.getlocalelist.example-1"></a><p class="title"><b>Example 25.22. getLocaleList()</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$localelist = Zend_Locale::getLocaleList();

            </pre></div>
</div>
<br class="example-break"><div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
                Note that the locales are returned as key of the array you will receive. The value is always
                a boolean true.
            </p></td></tr>
</table></div>
</div>
</div>
<div class="navfooter"><table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="zend.locale.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="zend.locale.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="zend.locale.parsing.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Chapter 25. Zend_Locale </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> 25.3. Normalization and Localization</td>
</tr>
</table></div>
<div class="revinfo"></div>
</body>
</html>
